
var titleIndex = $('title').attr('data-ind'); //获取title 的attr 属性
var titleUrl    = {};  // 用于存放url 内的参数  act=index&op=special&special_id=2
var severUrl = 'http://47.89.20.150/czlycmsCN/';









var PhotosNavArray = [];  //相册对象存储

var PhotosObj = null;  //相册对象存储



// 引入header
// loadHeader();






function windowScrollFun(){

	var navCon = $('#header');

	$(window).scroll(function(){
        var before = $(window).scrollTop();
        $(window).scroll(function() {
            var after = $(window).scrollTop();

            if (before<after) {
                // console.log('下');
                before = after;
                // console.log(after);
                if (after <= 150 ) {
               		 navCon.css('top', (-after)+'px');
                }else if (after >= 500){

                	navCon.css('top', '-120px');

                }




            };

            if (before>after) {
                // console.log('上');
                before = after;
                // console.log(after);
               
                	navCon.css({
                		'top': '0px',
                		'transition': 'all 0.7s',
                	});



            };

            if (after >700) {
				$('#goTop').show();

			}else{
				$('#goTop').hide();

			}
        });
    });

    $("html,body").on('click','#goTop',function() {
    	// body...
		$("html,body").animate({scrollTop: 0}, 300);

    })



}

windowScrollFun();



function loadHeader(){
	var header  = $('#header');
	header.load('header/index.html');
}

function loadFooter(){
	var footer = $('#FooterCon');
	footer.load('footer/index.html');
}
loadFooter()


function zhuanjson() {
	var ObjVal = window.location.href.split('#')[0].substring(window.location.href.split('#')[0].indexOf('?')+1).split("&");
	for(var i=0;i<ObjVal.length;i++){titleUrl[ObjVal[i].substr(0,ObjVal[i].indexOf('='))]=decodeURI(ObjVal[i].substring(ObjVal[i].indexOf('=')+1))};
}
zhuanjson();




// ButSearch

function ButSearchFun(){
		console.log('ButSearch');

		$('#header').find('div#HeadSearch').show();

	
}

function guanbiSearchFun(){
	console.log('guanbiSearchFun');

	var ind = $('#header').find('div#HeadSearch').find('input').val();

	console.log(ind.length);
	if (ind.length <= 0) {
		$('#header').find('div#HeadSearch').hide();

	}else{
		window.location.href = 'search.html?searchName='+ind;
	}


}

function ButSearch(){
	$('#header').on('click','li#ButSearc',function(){
		console.log('ButSearch')

		$('#header').find('div#HeadSearch').show();
	})

	
}


ButSearch();

// ButSearch


   //NAV导航控制
   function NAVset(){
   	var NaW = $('#InOneNavList');
   	var NavHDlst = $('#NavHDlst') ;
   	var naTwoWai = $('#naTwoWai');
   	var SetTime = null;
   	var Oind = 0;
   	NaW.on("mouseover mouseout",'li',function(event){
   		Oind = $(this).index();
		 if(event.type == "mouseover"){
		  //鼠标悬浮
		  clearTimeout(SetTime);
		  naTwoWai.addClass('active');
		  NavHDlst.children('li').eq(Oind).show().siblings().hide();
		  event.stopPropagation();
		 }else if(event.type == "mouseout"){
		  //鼠标离开
		  	settimeFun();
		  	event.stopPropagation();
		 }
		})

   	NavHDlst.on("mouseover mouseout",function(event){
		 if(event.type == "mouseover"){
		  //鼠标悬浮
		  clearTimeout(SetTime);
		  naTwoWai.addClass('active');
		  event.stopPropagation();

		 }else if(event.type == "mouseout"){
		  //鼠标离开
		  	settimeFun();
		  	event.stopPropagation();
		 }
		})

   	NavHDlst.on("mouseover",'ul.naNoe',function(event){
	 	$(this).on("mouseover",'li',function(){
	 		$(this).addClass('active').siblings().removeClass('active');
	 		$(this).parent('ul.naNoe').siblings('ul.naTwo').children('li').eq($(this).index()).show().siblings().hide();
	 		})
		})


   	function settimeFun(){
   		SetTime = setTimeout(function(){
		  		naTwoWai.removeClass('active');
		  	},500)
   	}

   }

    // NAVset();
   //NAV导航控制 end//NAV导航控制 end






	// 首页轮播图
	function callSweiper(){
		MySweiper = new Swiper ('.indexBanner', {
			    // direction: 'vertical',
			    loop: true,
			    autoplay : 5000,
			    // 如果需要分页器
			    pagination: '.swiper-pagination',
			    paginationClickable :true,
			    
			    // 如果需要前进后退按钮
			    nextButton: '.nextinbanner',
			    prevButton: '.previnbanner',
			    
			    // 如果需要滚动条
			    // scrollbar: '.swiper-scrollbar',

			     onInit: function(swiper){ //Swiper2.x的初始化是onFirstInit
			    	swiperAnimateCache(swiper); //隐藏动画元素 
			    	swiperAnimate(swiper); //初始化完成开始动画
			    }, 
			    onSlideChangeEnd: function(swiper){ 
				    swiperAnimate(swiper); //每个slide切换结束时也运行当前slide动画
				} 
			})  



	}
	// callSweiper();
	// 首页轮播图 end
















//时间戳 转换方法
	Date.prototype.Format = function(fmt)   
	{ //author: meizz   
	  var o = {   
	    "M+" : this.getMonth()+1,                 //月份   
	    "d+" : this.getDate(),                    //日   
	    "h+" : this.getHours(),                   //小时   
	    "m+" : this.getMinutes(),                 //分   
	    "s+" : this.getSeconds(),                 //秒   
	    "q+" : Math.floor((this.getMonth()+3)/3), //季度   
	    "S"  : this.getMilliseconds()             //毫秒   
	  };   
	  if(/(y+)/.test(fmt))   
	    fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
	  for(var k in o)   
	    if(new RegExp("("+ k +")").test(fmt))   
	  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
	  return fmt;   
	}  


	//时间戳 转换方法 end

	//判断 当前 日期是否和上一日期相同
	function ifTimeTrue(topTime,thisTime,nian,yue,ri,lang){
		if (topTime == thisTime) {
			return '';
		}else{
			return '<a href="'+ '#'+lang +'"><span class="nian">'+nian+'</span><span class="yue">'+yue+'</span></a>';
		}
	}
	//判断 当前 日期是否和上一日期相同 end




//第一个 show

function IfOneShow(l){
    if (l == 0) {
        return 'display: block;';
    }else{
     return ' ';
 }
}
//第一个 show end

//第一个 样式改变

function IfOne(i){
    if (i == 0) {
        return 'active';
    }else{
     return ' ';
 }
}

//第一个 样式改变 end

//PHOTOS 弹出 相框 
function PhotosFrameFun(){
	var Con = $('#PhotosFrame');
	var Exit = $('#ExitPhotosFrame');
	var next = Con.find('.nextFrame');
	var prev = Con.find('.prevFrame');
	var imgCon = Con.find('.imgCon');

	var NCon = $('#photosCon');
	var img = NCon.find('img.photo');
	

	var Dataimg = [];
	var index = 0;

	for (var i = 0; i < img.length; i++) {

		Dataimg[i] = img.eq(i).attr('src');
	}

	// console.log(Dataimg);
	// console.log(Dataimg.length);

	NCon.on('click','span.iconCn',function(){
		index =  parseInt($(this).parents('a').find('img').attr('data-in'));
		imgCon.find('img').attr('src',Dataimg[index]);




		Con.show();
		setTimeout(function(){
			imgCon.addClass('active')
		},1)

	})

	next.click(function(){
		index--;
		if (index < 0) {
			index = (Dataimg.length - 1);
		}
		console.log(index)
		imgCon.find('img').attr('src',Dataimg[index]);
	})
	
	prev.click(function(){
		index++;
		if (index >(Dataimg.length - 1)) {
			index = 0;
		}
		console.log(index)

		imgCon.find('img').attr('src',Dataimg[index]);
	})

	Exit.click(function(){
		imgCon.removeClass('active')
		setTimeout(function(){
			Con.hide();
		},300)
	})
}
// PhotosFrameFun();

//PHOTOS 弹出 相框 end




// 替换josn数据里的字符

function expandEntities(data) {
	var string = null;
	if (data.length != 0) {
		 string = data.replace(/\&lt;/g,"<").replace(/\&gt;/g,">").replace(/\&amp;/g,"&").replace(/\&nbsp;/g,' ').replace(/\&quot;/g,'"');
	}
    return string;
}
// 替换josn数据里的字符 end